<%@ page import="cn.org.eshow.component.qiniu.QiniuConfig" %>
<script src="${dll}/fileupload/js/vendor/jquery.ui.widget.js"></script>
<script src="${dll}/fileupload/js/jquery.iframe-transport.js"></script>
<script src="${dll}/fileupload/js/jquery.fileupload.js"></script>
<script type="text/javascript">

    /**
     * 图片上传
     * @param _previewImg 浏览图标签ID
     * @param _upimg      接收图片input ID
     * @param _fileupload fileupload标签ID
     */
    function fileUp(_previewImg, _upimg, _fileupload) {
        //logo上传
        var url = 'http://up.qiniu.com/';
        var key = "";
        $("#" + _fileupload).click();
        var time = new Date();
        key = time.getFullYear() + '/' + (time.getMonth() + 1) + '/' + time.getDate() + '/' + Date.parse(time);
        $('#' + _fileupload).fileupload({
            url: url,
            dataType: 'json',
            post: 'POST',
            formData: {
                key: key,
                token: "<%=cn.org.eshow.component.qiniu.QiniuUtil.uploadToken(QiniuConfig.BUCKET)%>"
            },
            done: function (e, data) {
                $("#" + _previewImg).attr("src", "<%=QiniuConfig.URL%>/" + key + "!small.jpg");
                $("#" + _upimg).val("<%=QiniuConfig.URL%>/" + key);
            }
        }).prop('disabled', !$.support.fileInput)
                .parent().addClass($.support.fileInput ? undefined : 'disabled');


    }

</script>